package com.example.satu.quizcreator.quiz_creator;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.satu.quizcreator.quiz.Answer;
import com.example.satu.quizcreator.R;

/**
 * Created by Satu on 2014-11-13.
 */
public class AnswerView extends LinearLayout {

    EditText answerBody;
    ImageView imageView;

    public AnswerView(Context context,Answer answer) {
        super(context);
        initWidget();
        setAnswer(answer);
    }

    public AnswerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initWidget();
    }

    public AnswerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initWidget();
    }
    private void initWidget(){
        LayoutInflater.from(getContext()).inflate(R.layout.answer_widget_description,this);

        answerBody = (EditText) findViewById(R.id.simple_answer_item);
        imageView = (ImageView) findViewById(R.id.file_loaded_view);

        answerBody.setOnFocusChangeListener(new OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus)
                    Toast.makeText(getContext(),"click",Toast.LENGTH_SHORT).show();
                else
                    Toast.makeText(getContext(),"unclick",Toast.LENGTH_SHORT).show();
            }
        });
    }
    public void setAnswer(Answer answer){
        answerBody.setText(answer.getBody());

    }

}
